package com.jsnj33.pdaproject.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.text.Editable;
import android.text.TextWatcher;
import android.text.method.ScrollingMovementMethod;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import com.jsnj33.pdaproject.R;
import com.jsnj33.pdaproject.bean.PayingBillsBean;
import com.jsnj33.pdaproject.utils.StringUtility;

import java.util.List;

/**
 * @author 33oa
 * @date 2018/11/29
 */
public class PayingBillsAdapter extends RecyclerView.Adapter<PayingBillsAdapter.ViewHolder> {

    private Context mContext;
    private List<PayingBillsBean.TfBean> list;

    public PayingBillsAdapter(Context context) {
        this.mContext = context;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_paying_bills, parent, false);
        ViewHolder viewHolder = new ViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(final ViewHolder holder, final int position) {
        PayingBillsBean.TfBean tfBean = list.get(position);
        holder.tv_ord_no.setText(tfBean.getPrd_no());
        holder.tv_name.setText(tfBean.getPrd_name());
        holder.tv_spc.setText(tfBean.getSpc());
        holder.tv_rem.setText(tfBean.getRem());
        holder.tv_wh.setText(tfBean.getWh());
        holder.tv_bat_no.setText(tfBean.getBat_no());
        holder.tv_qty.setText(tfBean.getQty() + "");
        holder.tv_number.setText(tfBean.getSmqty()+"");
    }

    @Override
    public int getItemCount() {
        return list != null ? list.size() : 0;
    }

    public void setList(List<PayingBillsBean.TfBean> list) {
        this.list = list;
        notifyDataSetChanged();
    }

    class ViewHolder extends RecyclerView.ViewHolder {

        private TextView tv_ord_no;
        private TextView tv_name;
        private TextView tv_spc;
        private TextView tv_rem;
        private TextView tv_wh;
        private TextView tv_bat_no;
        private TextView tv_qty;
        private TextView tv_number;

        ViewHolder(View itemView) {
            super(itemView);
            tv_ord_no = itemView.findViewById(R.id.tv_ord_no);
            tv_name = itemView.findViewById(R.id.tv_name);
            tv_name.setMovementMethod(new ScrollingMovementMethod());
            tv_spc = itemView.findViewById(R.id.tv_spc);
            tv_rem = itemView.findViewById(R.id.tv_rem);
            tv_wh = itemView.findViewById(R.id.tv_wh);
            tv_bat_no = itemView.findViewById(R.id.tv_bat_no);
            tv_qty = itemView.findViewById(R.id.tv_qty);
            tv_number = itemView.findViewById(R.id.tv_number);
        }
    }
}
